<template>
  <div class="home">
    <!-- 搜索框 -->
    <search></search>

    <!-- 轮播图 -->
    <swiper></swiper>

    <!-- 分类 -->
    <category></category>

    <!-- 广告 -->
    <ad></ad>

    <!-- 推荐 -->
    <recommend></recommend>

    <!-- 楼层 -->
    <floors></floors>

    <!-- 热卖商品 -->
    <hot-goods></hot-goods>

    <!-- 底部菜单栏 -->
    <tab-bar></tab-bar>

    <button @click="send">发送eventBus</button>
  </div>
</template>

<script>
import * as api from "@/request/api/home.js";

import search from "./components/search";
import swiper from "./components/swiper";
import category from "./components/category";
import ad from "./components/ad";
import recommend from "./components/recommend";
import floors from "./components/floors";
import hotGoods from "./components/hotGoods";

export default {
  components: {
    search,
    swiper,
    category,
    ad,
    recommend,
    floors,
    hotGoods
  },
  data() {
    return {
      datas: {}
    };
  },
  methods: {
    async API_getIndexInfo() {
      //获取首页信息接口
      return await api.getIndexInfo();
    },
    send() {
      this.$router.push("/test");
    }
  },
  async created() {
    let res = await this.API_getIndexInfo();
    this.$eventBus.$emit("getIndexInfo", res.data.data);
  },
  beforeDestroy() {
    //销毁之前
    console.log(111111111);
    this.$eventBus.$emit("xxx", 123456);
  }
};
</script>

<style>
.home {
  padding-bottom: 50px;
}
</style>